package de.hs_mannheim.visualscheduler.scheduling;

import java.io.Serializable;

/**
 * The Class ProcessDefinition contains information describing one process.
 */
public class ProcessDefinition implements Serializable {
	private static final long	serialVersionUID	= 239493604730718251L;
	private int					runtime;
	private int					arrival;
	private int					priority;
	private String				name;

	/**
	 * Instantiates a new process definition.
	 * 
	 * @param runtime
	 *            of the process
	 * @param arrival
	 *            of the process
	 * @param priority
	 *            of the process
	 * @param name
	 *            of the process
	 */
	public ProcessDefinition(final int runtime, final int arrival, final int priority, final String name) {
		this.runtime = runtime;
		this.arrival = arrival;
		this.priority = priority;
		this.name = name;
	}

	@Override
	// Auto-generated
	public boolean equals(final Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(ProcessDefinition.class.isAssignableFrom(obj.getClass())))
			return false;
		final ProcessDefinition other = (ProcessDefinition) obj;
		if (arrival != other.arrival)
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (priority != other.priority)
			return false;
		if (runtime != other.runtime)
			return false;
		return true;
	}

	/**
	 * Gets the time of arrival. (In clock-cycles from start)
	 * 
	 * @return the arrival
	 */
	public int getArrival() {
		return arrival;
	}

	/**
	 * Gets the name.
	 * 
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * Gets the priority.
	 * 
	 * @return the priority
	 */
	public int getPriority() {
		return priority;
	}

	/**
	 * Gets the runtime. (In clock-cycles)
	 * 
	 * @return the runtime
	 */
	public int getRuntime() {
		return runtime;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + arrival;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + priority;
		result = prime * result + runtime;
		return result;
	}

	/**
	 * Sets the arrival.
	 * 
	 * @param arrival
	 *            the new arrival
	 */
	public void setArrival(final int arrival) {
		this.arrival = arrival;
	}

	/**
	 * Sets the name.
	 * 
	 * @param name
	 *            the new name
	 */
	public void setName(final String name) {
		this.name = name;
	}

	/**
	 * Sets the priority.
	 * 
	 * @param priority
	 *            the new priority
	 */
	public void setPriority(final int priority) {
		this.priority = priority;
	}

	/**
	 * Sets the runtime.
	 * 
	 * @param runtime
	 *            the new runtime
	 */
	public void setRuntime(final int runtime) {
		this.runtime = runtime;
	}
}
